package com.litong.litongjiaoyu.service.impl;

import com.litong.litongjiaoyu.dao.CommenDao;
import com.litong.litongjiaoyu.entity.StudentGroupByClassName;
import com.litong.litongjiaoyu.entity.TeacherUserinfo;
import com.litong.litongjiaoyu.service.CommenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName CommentServiceImpl
 * @Description TODO
 * @Author jingz
 * @Date 2019/7/18 13:29
 * @Version 1.0
 **/
@Service
public class CommentServiceImpl implements CommenService {
    
    @Autowired
    private CommenDao commenDao;
    
    /**
     * @param openId
     *
     * @return int
     * @Author jingz
     * @Description 查询是否有该OpenID
     * @Date 10:19 2019/7/18
     * @Param [OpenId]
     */
    @Override
    public int selectOpenID(String openId) {
        return commenDao.selectOpenID(openId);
    }
    
    /**
     * @param openId
     *
     * @return com.litong.litongjiaoyu.entity.Comment
     * @Author jingz
     * @Description 查询是否有该OpenID(老师专用)
     * @Date 13:59 2019/7/18
     * @Param [OpenId]
     */
    @Override
    public int selectOpenIDByTeacher(String openId) {
        return commenDao.selectOpenIDByTeacher(openId);
    }
    
    /**
     * @return java.util.List<java.lang.String>
     * @Author jingz
     * @Description 返回所有班级
     * @Date 22:04 2019/7/19
     * @Param []
     **/
    @Override
    public List<String> queryClass(String campus) {
        return commenDao.queryClass(campus);
    }
    
    /**
     * 获取可预约老师名单
     *
     * @return
     */
    @Override
    public List<TeacherUserinfo> getTeacher() {
        return commenDao.getTeacher();
    }
    
    /**
     * 获取openid(通用)
     *
     * @param phone
     *
     * @return
     */
    @Override
    public String getOpenId(String phone) {
        return commenDao.getOpenId(phone);
    }
    
    /**
     * 根据校区和功能获取openid
     *
     * @param camps
     * @param alias
     *
     * @return
     */
    @Override
    public List<String> getOpenIdByCampusAndFeatures(String camps, String alias) {
        return commenDao.getOpenIdByCampusAndFeatures(camps, alias);
    }
    
    /**
     * 根据班级和校区获取openid
     *
     * @param campus
     * @param classname
     *
     * @return
     */
    @Override
    public List<String> getOpenIdByClassAndCampus(String campus, String classname) {
        return commenDao.getOpenIdByClassAndCampus(campus, classname);
    }
    
    /**
     * 获取老师联系方式
     *
     * @return
     */
    @Override
    public List<TeacherUserinfo> callTeacher(String campus) {
        return commenDao.callTeacher(campus);
    }
    
    /**
     * 获取可以沟通的老师列表
     *
     * @param campus 学生所在校区
     *
     * @return 老师列表
     */
    @Override
    public List<TeacherUserinfo> getTeacherGroup(String campus) {
        return this.commenDao.getTeacherGroup(campus);
    }
    
    /**
     * 获取师生聊天中学生列表
     *
     * @param campus 所在校区
     *
     * @return 学生列表
     */
    @Override
    public List<StudentGroupByClassName> getStudentGroupWithClassName(String campus) {
        List<StudentGroupByClassName> studentGroupByClassNames = this.commenDao.getStudentGroupWithClassName(campus);
        
        if (studentGroupByClassNames.size() > 0) {
            return studentGroupByClassNames;
        } else {
            return new ArrayList<>();
        }
    }
}
